<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	<title>字段数据类型 | ElasticSearch 7.7 权威指南中文版</title>
	<meta name="keywords" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <meta name="description" content="ElasticSearch 权威指南中文版, elasticsearch 7, es7, 实时数据分析，实时数据检索" />
    <!-- Give IE8 a fighting chance -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
	<link rel="stylesheet" type="text/css" href="../static/styles.css" />
	<script>
	var _link = 'mapping-types.html';
    </script>
</head>
<body>
<div class="main-container">
    <section id="content">
        <div class="content-wrapper">
            <section id="guide" lang="zh_cn">
                <div class="container">
                    <div class="row">
                        <div class="col-xs-12 col-sm-8 col-md-8 guide-section">
                            <div style="color:gray; word-break: break-all; font-size:12px;">原英文版地址: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/7.7/mapping-types.html" rel="nofollow" target="_blank">https://www.elastic.co/guide/en/elasticsearch/reference/7.7/mapping-types.html</a>, 原文档版权归 www.elastic.co 所有<br/>本地英文版地址: <a href="../en/mapping-types.html" rel="nofollow" target="_blank">../en/mapping-types.html</a></div>
                        <!-- start body -->
                  <div class="page_header">
<strong>重要</strong>: 此版本不会发布额外的bug修复或文档更新。最新信息请参考 <a href="https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html" rel="nofollow">当前版本文档</a>。
</div>
<div id="content">
<div class="breadcrumbs">
<span class="breadcrumb-link"><a href="index.html">Elasticsearch 权威指南 [7.7]</a></span>
»
<span class="breadcrumb-link"><a href="mapping.html">映射</a></span>
»
<span class="breadcrumb-node">字段数据类型</span>
</div>
<div class="navheader">
<span class="prev">
<a href="removal-of-types.html">« 删除的映射类型</a>
</span>
<span class="next">
<a href="alias.html">alias(别名) »</a>
</span>
</div>
<div class="chapter">
<div class="titlepage"><div><div>
<h2 class="title">
<a id="mapping-types"></a>字段数据类型
</h2>
</div></div></div>
<p>Elasticsearch 中文档的字段支持多种不同的数据类型：</p>
<h3>
<a id="_core_datatypes"></a>核心数据类型
</h3>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
字符串(string)
</span>
</dt>
<dd>
<a class="xref" href="text.html" title="text 数据类型" rel="nofollow"><code class="literal">text</code></a> 和 <a class="xref" href="keyword.html" title="keyword 数据类型" rel="nofollow"><code class="literal">keyword</code></a>
</dd>
<dt>
<span class="term">
<a class="xref" href="number.html" title="numeric 数据类型" rel="nofollow">数值 (numeric)</a>
</span>
</dt>
<dd>
<code class="literal">long</code>、<code class="literal">integer</code>、<code class="literal">short</code>、<code class="literal">byte</code>、<code class="literal">double</code>、<code class="literal">float</code>、<code class="literal">half_float</code>、<code class="literal">scaled_float</code>
</dd>
<dt>
<span class="term">
<a class="xref" href="date.html" title="date 数据类型" rel="nofollow">日期(Date)</a>
</span>
</dt>
<dd>
<code class="literal">date</code>
</dd>
<dt>
<span class="term">
<a class="xref" href="date_nanos.html" title="Date nanoseconds 数据类型" rel="nofollow">日期纳秒(date nanoseconds)</a>
</span>
</dt>
<dd>
<code class="literal">date_nanos</code>
</dd>
<dt>
<span class="term">
<a class="xref" href="boolean.html" title="boolean 数据类型" rel="nofollow">布尔(boolean)</a>
</span>
</dt>
<dd>
<code class="literal">boolean</code>
</dd>
<dt>
<span class="term">
<a class="xref" href="binary.html" title="binary 数据类型" rel="nofollow">二进制(binary)</a>
</span>
</dt>
<dd>
<code class="literal">binary</code>
</dd>
<dt>
<span class="term">
<a class="xref" href="range.html" title="range 数据类型" rel="nofollow">范围(range)</a>
</span>
</dt>
<dd>
<code class="literal">integer_range</code>、<code class="literal">float_range</code>、<code class="literal">long_range</code>、<code class="literal">double_range</code>、<code class="literal">date_range</code>、<code class="literal">ip_range</code>
</dd>
</dl>
</div>
<h3>
<a id="_complex_datatypes"></a>复杂的数据类型
</h3>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<a class="xref" href="object.html" title="object 数据类型" rel="nofollow">对象(object)</a>
</span>
</dt>
<dd>
单个JSON对象的<code class="literal">object</code>
</dd>
<dt>
<span class="term">
<a class="xref" href="nested.html" title="Nested datatype">嵌套(nested)</a>
</span>
</dt>
<dd>
JSON数组对象的嵌套(<code class="literal">nested</code>)
</dd>
</dl>
</div>
<h3>
<a id="_geo_datatypes"></a>地理(geo)数据类型
</h3>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<a class="xref" href="geo-point.html" title="geo-point 数据类型" rel="nofollow">地理坐标点(geo-point)</a>
</span>
</dt>
<dd>
<code class="literal">geo_point</code>：用于表示经纬度坐标点
</dd>
<dt>
<span class="term">
<a class="xref" href="geo-shape.html" title="geo-shape 数据类型" rel="nofollow">地理形状(geo-shape)</a>
</span>
</dt>
<dd>
<code class="literal">geo_shape</code>：用于表示多边形等复杂形状
</dd>
</dl>
</div>
<h3>
<a id="_specialised_datatypes"></a>特殊的数据类型
</h3>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<a class="xref" href="ip.html" title="IP 数据类型" rel="nofollow">IP</a>
</span>
</dt>
<dd>
<code class="literal">ip</code>：用于IPv4和IPv6地址
</dd>
<dt>
<span class="term">
<a class="xref" href="search-suggesters.html#completion-suggester" title="completion suggester 数据类型" rel="nofollow">完成(completion)数据类型</a>
</span>
</dt>
<dd>
<code class="literal">completion</code>：提供自动完成建议
</dd>
<dt>
<span class="term">
<a class="xref" href="token-count.html" title="token count 数据类型" rel="nofollow">词元计数(token count)</a>
</span>
</dt>
<dd>
<code class="literal">token_count</code>：用于计算一个字符串中词元的数量
</dd>
<dt>
<span class="term">
<a href="https://www.elastic.co/guide/en/elasticsearch/plugins/7.7/mapper-murmur3.html" class="ulink" target="_top" rel="nofollow"><code class="literal">mapper-murmur3</code></a>
</span>
</dt>
<dd>
<code class="literal">murmur3</code>：用于在编制索引时计算值的散列并将它们存储在索引中的
</dd>
<dt>
<span class="term">
<a href="https://www.elastic.co/guide/en/elasticsearch/plugins/7.7/mapper-annotated-text.html" class="ulink" target="_top" rel="nofollow"><code class="literal">mapper-annotated-text</code></a>
</span>
</dt>
<dd>
<code class="literal">annotated-text</code>：对包含特殊标记的文本进行索引(通常用于标识命名实体)
</dd>
<dt>
<span class="term">
<a class="xref" href="percolator.html" title="percolator 数据类型" rel="nofollow">Percolator</a>
</span>
</dt>
<dd>
接受来自 Query-DSL 的查询
</dd>
<dt>
<span class="term">
<a class="xref" href="parent-join.html" title="join 数据类型" rel="nofollow">连接(join)</a>
</span>
</dt>
<dd>
为同一索引中的文档定义父-子关系
</dd>
<dt>
<span class="term">
<a class="xref" href="rank-feature.html" title="rank feature 数据类型" rel="nofollow">排名特征(rank feature)</a>
</span>
</dt>
<dd>
记录数字特征以提高查询时的命中率。
</dd>
<dt>
<span class="term">
<a class="xref" href="rank-features.html" title="rank features 数据类型" rel="nofollow">排名特征(rank features)</a>
</span>
</dt>
<dd>
记录(多个)数字特征以提高查询时的命中率。
</dd>
<dt>
<span class="term">
<a class="xref" href="dense-vector.html" title="dense vector 数据类型" rel="nofollow">密集向量(dense vector)</a>
</span>
</dt>
<dd>
记录浮点值的密集向量。
</dd>
<dt>
<span class="term">
<a class="xref" href="sparse-vector.html" title="Sparse vector 数据类型" rel="nofollow">稀疏向量(sparse vector)</a>
</span>
</dt>
<dd>
记录浮点值的稀疏向量。
</dd>
<dt>
<span class="term">
<a class="xref" href="search-as-you-type.html" title="Search-as-you-type 数据类型" rel="nofollow">输入即搜索(search-as-you-type)</a>
</span>
</dt>
<dd>
一个类似文本的字段，针对查询进行了优化，以实现随输入的自动完成
</dd>
<dt>
<span class="term">
<a class="xref" href="alias.html" title="alias 数据类型" rel="nofollow">别名(alias)</a>
</span>
</dt>
<dd>
定义现有字段的别名。
</dd>
<dt>
<span class="term">
<a class="xref" href="flattened.html" title="flattened 数据类型" rel="nofollow">展开(flattened)</a>
</span>
</dt>
<dd>
允许将整个JSON对象作为单个字段进行索引。
</dd>
<dt>
<span class="term">
<a class="xref" href="shape.html" title="shape 数据类型" rel="nofollow">形状(shape)</a>
</span>
</dt>
<dd>
任意笛卡尔几何图形的形状(<code class="literal">shape</code>)。
</dd>
<dt>
<span class="term">
<a class="xref" href="histogram.html" title="histogram 数据类型" rel="nofollow">直方图(histogram)</a>
</span>
</dt>
<dd>
<code class="literal">histogram</code>，百分位数聚合的预聚合数值直方图。
</dd>
<dt>
<span class="term">
<a class="xref" href="constant-keyword.html" title="constant keyword 数据类型" rel="nofollow">常量关键字(constant keyword)</a>
</span>
</dt>
<dd>
当所有文档具有相同值时，会将<code class="literal">keyword</code>特殊化处理。
</dd>
</dl>
</div>
<h3>
<a id="types-array-handling"></a>数组
</h3>
<p>
在Elasticsearch中，数组不需要专门的字段数据类型。

默认情况下，任何字段都可以包含零个或多个值，但是，数组中的所有值都必须具有相同的数据类型。请参见<a class="xref" href="array.html" title="arrays" rel="nofollow">数组</a>。
</p>
<h3>
<a id="_multi_fields"></a>多字段(multi-fields)
</h3>
<p>
出于不同的目的，以不同的方式索引同一个字段通常是有用的。

例如，一个<code class="literal">string</code>字段可以映射为用于全文搜索的<code class="literal">text</code>字段，也可以映射为用于排序或聚合的<code class="literal">keyword</code>字段。

或者，可以使用<a class="xref" href="analysis-standard-analyzer.html" title="standard 分析器" rel="nofollow"><code class="literal">standard</code>分析器</a>、<a class="xref" href="analysis-lang-analyzer.html#english-analyzer" title="english 分析器" rel="nofollow"><code class="literal">english</code>分析器</a>、<a class="xref" href="analysis-lang-analyzer.html#french-analyzer" title="french 分析器" rel="nofollow"><code class="literal">french</code>分析器</a>来索引一个<code class="literal">text</code>字段。
</p>
<p>
这就是<em>多字段(multi-fields)</em>的目的。

大多数数据类型可以通过<a class="xref" href="multi-fields.html" title="字段" rel="nofollow"><code class="literal">fields</code></a>参数支持多字段。
</p>



























</div>
<div class="navfooter">
<span class="prev">
<a href="removal-of-types.html">« 删除的映射类型</a>
</span>
<span class="next">
<a href2="alias.html">alias(别名) »</a>
</span>
</div>
</div>

                  <!-- end body -->
                        </div>
                        <div class="col-xs-12 col-sm-4 col-md-4" id="right_col">
                        
                        </div>
                    </div>
                </div>
            </section>
        </div>
    </section>
</div>
<script src="../static/cn.js"></script>
</body>
</html>